package net.zjitc.controller;

import net.zjitc.pojo.Category;
import net.zjitc.pojo.Product;
import net.zjitc.service.AdminProductService;
import net.zjitc.service.CategoryService;
import net.zjitc.service.impl.AdminProductServiceImpl;
import net.zjitc.service.impl.CategoryServiceImpl;
import net.zjitc.utils.dispacher.URLMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Created by lenovo on 2017/12/5.
 */
public class IndexController {
    CategoryService categoryService = new CategoryServiceImpl();
    AdminProductService adminProductService = new AdminProductServiceImpl();
    @URLMapping(url = "/index")
    public String index(HttpServletRequest request, HttpServletResponse response){
        List<Category> clist = categoryService.findAll();
        request.setAttribute("clist",clist);

        List<Product> plist=adminProductService.findHot();
        request.setAttribute("plist",plist);

        List<Product> aclist=adminProductService.findNew();
        request.setAttribute("aclist",aclist);

        return "/WEB-INF/user/index.jsp";
    }
}
